<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>:: Calendar</title>
<LINK rel="stylesheet" type="text/css" href="../css/cal_Style.css">
</head>
<body>
<table width="280"  border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td><span id="spnMonth1"></span></td>
		<td><span id="spnMonth2"></span></td>
	</tr>
</table>
<script type='text/javascript'>
<!--
// --------------------
var strinDate = "15/02/2006";
// --------------------
var arrMonth = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var arrDayDesc  = ["S", "M", "T", "W", "T", "F", "S"];

var arrDays = new Array(42);

var now		= new Date();
var day		= now.getDate();
var month	= now.getMonth();
var year	= now.getFullYear();
var intYearP = 2;
var intYearF = 10;

var intDisableUpto = "";
var intDisableFrom = "";
var intDisableUptoMMYY = "";
var intDisableFromMMYY = "";
var intInDD = 0
var intInMM = 0
var intInYY = 0
var strLastMonth = "";
var strPGImgPath = "../../images/";

function SetDate(strDD, strMM, strYY, strYears, strObject, strDisableUpto, strTextStyle, strDisableFrom, strYearRange, strImagePath, arrObjMonths, arrObjDays, strParamPgDir){
	
	blnFirst = true;
	intSYear= year ;	
	objParent = strObject;
	intDisableUpto = "";
	strPGImgPath = strImagePath;

	if (arrObjMonths != null){
		arrMonth = arrObjMonths;
	}

	if (arrObjDays != null){
		arrDayDesc = arrObjDays;
	}
	if (strParamPgDir != null){
		document.dir = strParamPgDir;
	}
	
	
	if (strDisableUpto != "" && strDisableUpto !=  null){
		var arrDUpto = strDisableUpto.split("/");
		if (Number(arrDUpto[0]) < 10){arrDUpto[0] = "0" + Number(arrDUpto[0])}
		arrDUpto[1] = Number(arrDUpto[1]) - 1;
		if (Number(arrDUpto[1]) < 10){arrDUpto[1] = "0" + Number(arrDUpto[1])}
		intDisableUpto = arrDUpto[2] + arrDUpto[1] + arrDUpto[0];
		intSYear = arrDUpto[2];
		intDisableUptoMMYY =  arrDUpto[2] + arrDUpto[1];
	}
	
	if (strDisableFrom != "" && strDisableFrom !=  null){
		var arrDUpto = strDisableFrom.split("/");
		if (Number(arrDUpto[0]) < 10){arrDUpto[0] = "0" + Number(arrDUpto[0])}
		arrDUpto[1] = Number(arrDUpto[1]) - 1;
		if (Number(arrDUpto[1]) < 10){arrDUpto[1] = "0" + Number(arrDUpto[1])}
		intDisableFrom = arrDUpto[2] + arrDUpto[1] + arrDUpto[0];
		intDisableFromMMYY = arrDUpto[2] + arrDUpto[1];
	}
	
	intInDD = strDD;
	intInMM = strMM - 1;
	intInYY = strYY;
	
	if (strDD == ""){strDD = "01";}
	strinDate = strDD + "/" + strMM + "/" + strYY;
	writeCalendar(strinDate);
}

function writeCalendar(strDate){
	var arrInDate = strDate.split("/");
	
	// First Month
	var intInDD1 = Number(arrInDate[0]);
	var intInMM1 = Number(arrInDate[1]) - 1;
	var intInYY1 = Number(arrInDate[2]);	
	var strMonth1 = getCalendar(intInMM1, intInYY1, 0);
	DivWrite("spnMonth1", strMonth1);
	
	// Second Month
	strLastMonth = addMonths(1,  strDate);
	arrInDate = strLastMonth.split("/");
	var intInDD2 = Number(arrInDate[0]);
	var intInMM2 = Number(arrInDate[1]) - 1;
	var intInYY2 = Number(arrInDate[2]);	
	
	var strMonth2 = getCalendar(intInMM2, intInYY2, 1);
	DivWrite("spnMonth2", strMonth2);
}

function changeMonth(strMove){
	if (strMove == "P"){
		strLastMonth = addMonths(-1,  strLastMonth);
	}else{
		strLastMonth = addMonths(0,  strLastMonth);
	}
	writeCalendar(strLastMonth)
}

function addMonths(intMonths){
	var dtToday = new Date();
	if (arguments.length == 2){
		if (arguments[1] != ""){
			dtToday = new Date(arguments[1].substr(6,4), Number(arguments[1].substr(3,2)) - 1, arguments[1].substr(0,2));
		}
	}
	
	// See if we got anything
	var dtTD = dtToday.getDate();
	
	// Retrieve the Date pieces
	var strMonth = null;
	if (intMonths < 0){
		strMonth = dtToday.getMonth() - (Math.abs(intMonths)  + 1);
	}else{
		strMonth = (dtToday.getMonth() + intMonths);
	}
	
	var strDay   = 1; //dtToday.getDate();
	var strYear  = dtToday.getFullYear();

	// Retrieve the Time pieces
	var strHour    = dtToday.getHours();
	var strMinutes = dtToday.getMinutes();
	var strSeconds = dtToday.getSeconds();
	var dtNew = new Date( strYear, strMonth, strDay, strHour, strMinutes, strSeconds);
	
	var dtNM = dtNew.getMonth() + 1;
	var dtND = dtNew.getDate();
	var dtNY = dtNew.getFullYear();
	
	if (Number(dtTD) > getDaysInMonth(dtNM, dtNY)){
		dtND = getDaysInMonth(dtNM, dtNY);
	}else{
		dtND = dtTD;
	}
	
	if (Number(dtND) < 10){dtND =  "0" + dtND;}
	if (Number(dtNM) < 10){dtNM =  "0" + dtNM;}
	
	// Create a new Date Object
	return dtND + "/" + dtNM + "/" + dtNY;
}

function getCalendar(strMonth, strYear, intMonth){
	// Array Initialize 
	strMonth = strMonth
	for (var i = 0; i <= 42; i++){
		arrDays[i] = "";
	}
	
	var intDays        = getDaysInMonth(strMonth + 1, strYear);
	var dtfirstDay     = new Date (strYear, strMonth, 1);
	var intArrStartPos = dtfirstDay.getDay();
	var strMMYY = String(strYear);
	if (strMonth < 10){strMMYY += "0" + strMonth;}else{strMMYY += strMonth;}
	
	
	// Get preivous month Days 
	var intPMonth	= strMonth;
	var intPYear	= strYear;
	if (intPMonth <= 0){
		intPMonth = 12
		intPYear  = Number(intPYear) - 1
	}
	var intPDays    = getDaysInMonth(intPMonth, intPYear);
	var intPSDate   = (intPDays - intArrStartPos + 1)
	
	var intDCount = 1 
	var intNDCount = 1 
	for (var i = 0; i <= 42; i++){
		if (i >= intArrStartPos){
			if (intDCount <= intDays){
				arrDays[i] = intDCount; 
				intDCount++;
			}else{
				arrDays[i] = intNDCount; 
				intNDCount++;
			}
		}else{
			arrDays[i] = intPSDate
			intPSDate++;
		}
	}
	
	var intTDWidth = 27	
	var intHDColspan = "8";
	var blnPrevView = true;
	var strHTMLText  = "<table width='" + (intTDWidth * 7) + " cellpadding='0' cellspacing='8'   border='0' class='BGColor tdOut' align='center'>"
	strHTMLText		+= "	<tr class='TblLineColor'>"
	if (intMonth == 0){
		if (intDisableUptoMMYY != ""){
			if (strMMYY > Number(intDisableUptoMMYY)){
				blnPrevView = false;
				intHDColspan = "6";
			}
		}else{
			intHDColspan = "6"
			blnPrevView = false;
		}
		if (!blnPrevView){
			strHTMLText	+= "		<td align='center' class='ToDateBGColor tdOut pointer' onclick=changeMonth('P')><img src='" + strPGImgPath + "prev.gif'><\/td>";
		}
		strHTMLText	+= "		<td colspan='" + intHDColspan + "' align='center'  class='ToDateBGColor tdOut'><b><font class='fontCalendar DefMonth'>" + arrMonth[strMonth] + "/" + strYear + "<\/font><\/b><\/td>"		
	}else{
		if (intDisableFromMMYY != ""){
			if (strMMYY < Number(intDisableFromMMYY)){
				intHDColspan = "6"
				blnPrevView = false;
			}
		}else{
			intHDColspan = "6"
			blnPrevView = false;
		}

		strHTMLText	+= "	<td colspan='" + intHDColspan + "' align='center'  class='ToDateBGColor tdOut'><b><font class='fontCalendar DefMonth'>" + arrMonth[strMonth] + "/" + strYear + "<\/font><\/b><\/td>"		
		if (!blnPrevView){
			strHTMLText	+= "		<td align='center'  class='ToDateBGColor tdOut pointer' onclick=changeMonth('N')><img src='" + strPGImgPath + "next.gif'><\/td>"
		}
	}
	strHTMLText		+= "	<\/tr>"
	strHTMLText		+= "	<tr class='TblLineColor'>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='SUHDBGColor tdOut'><font class='fontCalendar SUHDColor'><b>" + arrDayDesc[0] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='MOHDBGColor tdOut'><font class='fontCalendar MOHDColor'><b>" + arrDayDesc[1] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='TUHDBGColor tdOut'><font class='fontCalendar TUHDColor'><b>" + arrDayDesc[2] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='WEHDBGColor tdOut'><font class='fontCalendar WEHDColor'><b>" + arrDayDesc[3] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='THHDBGColor tdOut'><font class='fontCalendar THHDColor'><b>" + arrDayDesc[4] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='FRHDBGColor tdOut'><font class='fontCalendar FRHDColor'><b>" + arrDayDesc[5] + "<\/b><\/font><\/td>"
	strHTMLText		+= "		<td width='" + intTDWidth + "' align='center' class='SAHDBGColor tdOut'><font class='fontCalendar SAHDColor'><b>" + arrDayDesc[6] + "<\/b><\/font><\/td>"
	strHTMLText		+= "	<\/tr>"
	
	var intCount = 0 
	var strLinkTag = "";
	var intDCount = 1 
	
	for (var i = 0; i < 6; i++){
		strHTMLText		+= "	<tr class='TblLineColor'>"
		for (var x = 0; x < 7; x++){
			strHTMLText		+= " <td width='" + intTDWidth + "' align='right' " 
			if (intCount >= intArrStartPos){
				if (intDCount <= intDays){
					//strLinkTag = "<a href='#' onclick='Day_onClick(" + arrDays[intCount] + ")'>";
					strLinkTag = " onclick='Day_onClick(" + arrDays[intCount] + "," + strMonth + "," + strYear + ")' ";
					
					var strDisableUpto = strYear;
					var strDisableMonth = strMonth
					var strDisableDay = arrDays[intCount] ;
					
					if (Number(strDisableMonth) < 10){
						strDisableMonth = "0" + strDisableMonth;
					}
					
					if (Number(strDisableDay) < 10){
						strDisableDay = "0" + strDisableDay;
					}
					strDisableUpto = strDisableUpto + String(strDisableMonth) + String(strDisableDay);
					if (intDisableUpto != "" && intDisableUpto != null && strDisableUpto < intDisableUpto){
						strHTMLText += "class='DisableBGUpto tdIn'><font class='fontCalendar DisableUpto'><del>" + arrDays[intCount] + "<\/del><\/font><\/td>";
					}else{
						if (intDisableFrom != "" && intDisableFrom != null && strDisableUpto > intDisableFrom){
							strHTMLText += "class='DisableBGUpto tdIn'><font class='fontCalendar DisableUpto'><del>" + arrDays[intCount] + "<\/del><\/font><\/td>";
						}else{
							// Check is it current date 
							if (strMonth == intInMM && strYear == intInYY && arrDays[intCount] == intInDD){
								strHTMLText += "class='SelDateBGColor  pointer' " + strLinkTag + "><font class='fontCalendar SelDate'><b>" + arrDays[intCount] + "<\/b>";
							}else{
								if (strMonth == month && strYear == year && arrDays[intCount] == day){
									strHTMLText += "class='ToDateBGColor tdIn  pointer' " + strLinkTag + " ><font class='fontCalendar ToDate'><b>" + arrDays[intCount] + "<\/b>";
								}else{
									switch (x) {
										case 0 : strHTMLText += "class='SUBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar SUColor'>" + arrDays[intCount]; break;
										case 1 : strHTMLText += "class='MOBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar MOColor'>" + arrDays[intCount]; break;
										case 2 : strHTMLText += "class='TUBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar TUColor'>" + arrDays[intCount]; break;
										case 3 : strHTMLText += "class='WEBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar WEColor'>" + arrDays[intCount]; break;
										case 4 : strHTMLText += "class='THBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar THColor'>" + arrDays[intCount]; break;
										case 5 : strHTMLText += "class='FRBGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar FRColor'>" + arrDays[intCount]; break;
										case 6 : strHTMLText += "class='SABGColor tdOut pointer'" + strLinkTag + "><font class='fontCalendar SAColor'>" + arrDays[intCount]; break;
									}	
								}
							}
						}
					}
					strHTMLText	+= "<\/font><\/td>"
					intDCount++;
				}else{
					//strHTMLText += "class='DisableDaysBGColor'><font class='DisableDays'>" + arrDays[intCount] + "<\/font><\/td>";
					strHTMLText += "class='DisableDaysBGColor tdOut'><font class='fontCalendar DisableDays'>&nbsp;<\/font><\/td>";
				}
			}else{
				//strHTMLText += "class='DisableDaysBGColor'><font class='DisableDays'>" + arrDays[intCount] + "<\/font><\/td>";
				strHTMLText += "class='DisableDaysBGColor tdOut'><font class='fontCalendar DisableDays'>&nbsp;<\/font><\/td>";
			}
			intCount++
		}
		strHTMLText		+= "	<\/tr>"
	}
	
	strHTMLText		+= "<\/table>"
	return strHTMLText;
}

function Day_onClick(strDay, strMM, strYY){
	strMM = String(Number(strMM) + 1)
	if (strDay < 10){strDay = "0" + strDay}
	if (strMM < 10){strMM = "0" + strMM}
	//alert(strDay + "\n" + strMM + "\n" + strYY + "\n" + objParent)
	parent.DateReturn(strDay, strMM, strYY, objParent); 
	strinDate = strDay + "/" + strMM + "/" + strYY;
	/*
	SetCurrDate();
	window.close();
	*/
}

// --------------------
// Days in the Month
function getDaysInMonth(month,year)  {
	var days;
	if (month==1 || month==3 || month==5 || month==7 || month==8 ||
		month==10 || month==12)  days=31;
	else if (month==4 || month==6 || month==9 || month==11) days=30;
	else if (month==2)  {
		if (isLeapYear(year)) {
			days=29;
		}
		else {
			days=28;
		}
	}
	return (days);
}


// CHECK TO SEE IF YEAR IS A LEAP YEAR
function isLeapYear (Year) {
	if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
		return (true);
	}
	else {
		return (false);
	}
}

// ----------------------
function DivWrite(id, text){
	if (document.getElementById)
	{	x = document.getElementById(id);
		x.innerHTML = "";
		x.innerHTML = text;
	}
	else if (document.all)
	{
		x = document.all[id];
		x.innerHTML = text;
	}
	else if (document.layers)
	{
		x = document.layers[id];
		x.document.open();
		x.document.write(text);
		x.document.close();
	}
} 
var blnCalendarLoaded = true;
// --------------------

SetDate("01", "06", "2005", "4", "", "", null, null, null);
//-->
</script>
</body>
</html>

